Smart Buttons
Controls/XML Elements

API Call <APICall>

This control allows agents to:

  • Send information to an external database via the API.

  • Receive back information from that source.

Note:

  • The connection protocol for <APICall> control is HTTP.

  • This control needs two-way integration, which means that the API needs to be prepared (endpoint created). This API endpoint must be able to handle variables (request parameters) received from Smart Button scripts.

Configuring

You can configure APICall in the Smart Buttons Editor using either the API Call XML Generator or XML.

Configuring with the API Call XML Generator

The simplest way to use APICall functionality is to configure using the XML Generator.

To configure with the XML Generator:

  1. Open the Smart Buttons Editor to create a script.

  2. Click API Call <ApiCall>.

  3. Configure the attributes.

    Attribute

    Description

    URL Enter the URL address for the API endpoint.
    Variable name

    enter variable name that will hold the answer from API as a response from API.

    Travelport Smart Buttons can only accept and consume responses from the API endpoint in these formats:

    • String

    • JSON array of strings

    • JSON array of Value/Key pair (string vs.string) (see example of response at the end of this topic)

    See example of the file at the end of this topic.

    Variables (request parameters)

    Enter the names of variables that you want to send via API to external database.

    If there is more than one variable, separate each variable with semicolon (;). For example:

    • PCC;Airline;PassengerName or with square brackets:

    • [PCC];[Airline];[PassengerName]

    HTTP method

    Select the HTTP method to use for the request:

    • GET: variables are passed as a query parameters

    • POST: variables are passed as a HTTP content in a specific format

    Authorization Specify the details of authorization to your API.
    Type

    Select the type of authorization:

    • Basic
      When an agent wants to send authentication credentials to the server. When selected you need to specify A Login and Password to your API Endpoint. when you submit the form, your login and password are encrypted using a variant of Base64.

    • Header Key
      When selected, you must specify a Header name and Header value.

      • Header name
        When the Editor is used, the Header Value is encrypted (to show the value in the XML code to the agents), and is displayed in curly brackets {}.

        For example: KeyAuthHeaderValue="{a3Nrc2pmb2l1MzI5dTMyb2l1MzJ1Zmg1}".

        If you do not want the Header Value to be encrypted, do NOT use the Editor. Instead, enter the KeyAuthHeaderValue attribute directly in the XML code to display unencrypted. For example: KeyAuthHeaderValue="ABCYZV.3452ZDf".

      • Header value
        Enter the Header value, for example, AuthToken.

    • No authorization
      If the API has no authorization select this option.

  4. Click SUBMIT.

Configuring with XML

If you do not want to use the XML Generator, you can enter the XML directly in the Travelport Smart Buttons Editor.

Tip! You can add the XML code directly to the editor by dragging and dropping the blue button for this control.

This is the structure of the APICall XML element.

Copy
<ApiCall VarName="" Parameters="" Method="GET" AuthType="HeaderKey" 
KeyAuthHeaderName="" KeyAuthHeaderValue="" AuthorizationHeaderValue=""></ApiCall>

This table contains all possible attributes and attributes values.

Attribute

Description

VarName Specify Variable, for example, CustomerNumber
Parameters

Enter variables separated by semicolon. For example: Price;PaxName;PCC

Method

POST

GET

AuthType

Basic

HeaderKey

Anonymous

AuthorizationHeaderValue If your authorization type is Basic, enter your authorization data
KeyAuthHeaderName If your authorization type is HeaderKey, enter your API endpoint authorization header name.
KeyAuthHeaderValue If your authorization type is HeaderKey, enter your API endpoint authorization header value.
Example 1

APICall XML structure for HTTP Method: GET, Authorization Type: HeaderKey, code generated by APICall GUI (HeaderAuthHeaderValue is encrypted)

Copy
<ApiCall VarName="TotalBalance" Url="https://myAPI/API/CustomerBalance" Parameters="CustomerNumber;CurrentPCC;PNRNumber" Method="GET" AuthType="HeaderKey" KeyAuthHeaderName="AuthToken" KeyAuthHeaderValue="{OTM0NzA5MjM0ODA5MG5ramZkaGtzamZkaA==}" />
Example 2

APICall XML structure for Http Method:POST, Authorization Type: Basic, code generated by APICall GUI (AuthorizationHeaderValue is encrypted)

Copy
<ApiCall VarName="InvoiceYesNo" Url="https://myAPI/demo/CheckInvoice" Parameters="CustomerNumber" Method="POST" AuthType="Basic" AuthorizationHeaderValue="Basic VXNlcjIzNDppb2V1cm9pdWVv" />

API Response

The following example is an API response that can be accepted and consumed by Smart Buttons.

Copy
-JSON string array of key value pair
JSON
[
{
"Key": "Pcc",
"Value": "73XV"
},
{
"Key": "CorporateCode", "Value": "342534567"
}
]

Examples

APICall can be used by any API. However, the following examples show how APICall can be used in various situations.

Commission for a Specific Airline

Information about commissions for each airline is stored in your mid-office system.

You can create a script that reads airline fares used in calculation and applies the correct commission. With APICall control, you can query your mid-office system for the commission for a specific airline in a PNR/Booking File. The mid-office system API can return the information.

Validating the Customer Balance

Before issuing a ticket, you can validate if your customer balance allows you to issue the ticket.

Typically, you have to check the balance manually by opening your back-office system and comparing the ticket price with Customer Balance. For example, you look in the PNR/Booking File that the price of the ticket is 100 EUR, then go to back office system to check the Customer Balance. And if the Customer Balance is less that the ticket price you cannot issue the ticket.

With Smart Buttons and APICall control this function can be automated. For example, you can send the following information and receive back the Customer Balance.

Variables-request parameters (information you could send to API):

  • CustomerNumber;CurrentPCC

  • Variable name (information you receive back from API): CustomerBalance

These variables are examples; you can define which elements you want to send via API as well as the variables names.

Automated issuing for invoices

Manually issuing invoices in your back office system can be automated with APICall.

  • Variables-request parameters: PaxName;CustomerNumber;FiledFareAmount;Airlines

  • Variable name: InvoiceNumber

With this control you can send information such as PaxName, CustomerNumber, FiledFareAmount, and Airlines information. The API can then issue the invoice and send back information with the invoice number.